package com.dean.db.service;

import com.dean.batch.entity.BaseEntity;
import com.dean.db.entity.ProcduceParam;
import com.dean.entity.DeanDbConnInfo;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 数据库操作通用方法
 */
public interface DbService<T extends BaseEntity> {
    /**
     * 执行sql
     * @param sql
     * @return
     */
    public int execute(DeanDbConnInfo connInfo, String sql, PreparedStatement statement , String ... params) throws SQLException;

    public T queryForObject(DeanDbConnInfo connInfo, String sql, ResultSet resultSet, Class<T> clazz , String ... params) throws SQLException, InstantiationException, IllegalAccessException;

    public List<T> queryForList(DeanDbConnInfo connInfo, String sql, ResultSet resultSet , Class<T> clazz, String ... params) throws SQLException, InstantiationException, IllegalAccessException;

    public Map<String,Object> queryForMap(DeanDbConnInfo connInfo,String sql,ResultSet resultSet , String ... params);

    public List<Map<String,Object>> queryForMapList(DeanDbConnInfo connInfo,String sql,ResultSet resultSet , String ... params);

    public Map<String,Object> callProc(DeanDbConnInfo connInfo, String procName,PreparedStatement statement , List<ProcduceParam> procParams);

}
